package com.wxy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;

//@Configuration
public class redisConfig2 {				//这种配置下存储的数据以jdk的格式存储，会出现错误
	@Bean(name = "redisTemplate2")
	public RedisTemplate<String,String> redisTemplate2(RedisConnectionFactory connectionFactory){
		RedisTemplate<String,String> redisTemplate=new RedisTemplate<String, String>();
		redisTemplate.setConnectionFactory(connectionFactory);
		redisTemplate.setKeySerializer(new JdkSerializationRedisSerializer());
		redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
		return redisTemplate;
	}
}
